home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld: Complete Mac Interactive
/
Macworld Complete Mac Interactive CD)(1994).iso
/
Software
/
More Shareware⁄Freeware
/
NIH Image 1.55 f (non fpu)
/
Macros
/
Gel Plotting Macros (old)
< prev
next >
Wrap
Text File
|
1994-01-11
|
5KB
|
181 lines
var {Global variables}
RoiLeft,RoiTop,RoiWidth,RoiHeight,PlotColor:integer;
GelWidth,GelHeight,MaxPlotWindowHeight,NeededSize:integer;
GelWindow,PlotWindow,PlotLeft,PlotTop,PlotWidth,PlotHeight:integer;
hMargin,vMargin,nLanes,SavePlotTop,PlotWindowSize:integer;
LeftMargin,TopMargin,RightMargin,BottomMargin:integer;
FirstBackgroundPlot:boolean;
macro 'Setup to Plot Gel [Z]';
{This macro, along with the Plot Lane macro, is used to generate profile}
{plots of the lanes in a one dimensional electoproretic gel.}
var
nPixels,mean,mode,min,max:real;
PlotWinHeight:integer;
begin
RequiresVersion(1.53);
PlotHeight:=175;
PlotWidth:=500;
MaxPlotWindowHeight:=720;
GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight);
if RoiWidth=0 then begin
PutMessage('The Setup macro expects the Gel to be displayed and the first lane outlined.');
exit;
end;
if PlotWidth<RoiWidth then PlotWidth:=RoiWidth;
if PlotWidth>(2*RoiWidth) then PlotWidth:=2*RoiWidth;
if RoiHeight>RoiWidth then begin
PutMessage('Lanes must be horizontal.');
exit;
end;
if nPics<>1 then begin
PutMessage('The window containing the gel should be the only image window open.');
exit;
end;
nLanes:=GetNumber('Number of lanes?',1);
GetPicSize(GelWidth,GelHeight);
MakeRoi(RoiLeft,RoiTop,RoiWidth,GelHeight-RoiTop);
Measure;
GetResults(nPixels,mean,mode,min,max);
hMargin:=5;
vMargin:=5;
LeftMargin:=38; {Changed in v1.53}
TopMargin:=10;
RightMargin:=20;
BottomMargin:=20;
PlotLeft:=hMargin-LeftMargin;
PlotTop:=vMargin-TopMargin;
SavePlotTop:=PlotTop;
PlotWinHeight:=nLanes*PlotHeight+2*vMargin;
if PlotWinHeight>MaxPlotWindowHeight then begin
PlotWinHeight:=MaxPlotWindowHeight;
PlotHeight:=(PlotWinHeight-2*vMargin)/nLanes;
end;
PlotWindowSize:=(PlotWidth+2*hMargin)*PlotWinHeight;
if PlotWindowSize>UndoBufferSize then begin
NeededSize:=(PlotWindowSize+0.05*PlotWindowSize) div 1024;
PutMessage('Use Preferences(Options Menu) to increase the Undo buffer size to at least ',NeededSize:1,'K.');
KillRoi;
exit;
end;
SetNewSize(PlotWidth+2*hMargin,PlotWinHeight);
SetForegroundColor(255);
SetBackgroundColor(0);
MakeNewWindow('Plots');
SetPlotSize(PlotWidth,PlotHeight);
min:=min-1;
if min<0 then min:=0;
max:=max+5;
if max>255 then max:=255;
SetPlotScale(cValue(min),cValue(max));
SetPlotLabels(false);
GelWindow:=1;
PlotWindow:=2;
SelectPic(GelWindow);
MakeRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight);
FirstBackgroundPlot:=true;
PlotColor:=1;
ResetCounter;
SetOptions('Area');
WandAutoMeasure(true);
AdjustAreas(true);
LabelParticles(false);
IncludeInteriorHoles(true);
SetFontSize(9);
SetText('Centered');
SetLineWidth(1);
end;
macro 'Plot Lane [P]';
var
left,top,width,height:integer;
GelNotCalibrated:boolean;
begin
if (GelWidth=0) or (nPics=1) then begin
PutMessage
('Before using the Plot Lane macro you must first use the Setup macro.');
Exit;
end;
GelNotCalibrated:=not Calibrated;
GetRoi(left,top,width,height);
MakeRoi(RoiLeft,top,RoiWidth,RoiHeight);
SetOption;
ColumnAveragePlot;
Copy;
SelectPic(PlotWindow);
MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
PlotHeight+TopMargin+BottomMargin);
Paste;
DoOr;
if GelNotCalibrated and (PlotTop=SavePlotTop) then begin
SetText('Left Justified; With Background');
MoveTo(PlotLeft+LeftMargin+6,PlotTop+TopMargin+1);
SetFontSize(12);
Write('Uncalibrated');
SetFontSize(9);
SetText('Centered; No Background');
end;
PlotTop:=PlotTop+PlotHeight-1;
SelectPic(GelWindow);
end;
macro 'Plot Background Lane [B]';
{Plot all lanes before plotting backgrounds. Unlike the lane plotting macro,}
{you are allowed to change the height of the selection.}
var
left,top,width,height:integer;
begin
if (GelWidth=0) or (nPics=1) then begin
PutMessage('Use Setup first.');
Exit;
end;
GetRoi(left,top,width,height);
MakeRoi(RoiLeft,top,RoiWidth,height);
ColumnAveragePlot;
Copy;
SelectPic(PlotWindow);
if FirstBackgroundPlot then begin
FirstBackgroundPlot:=false;
PlotTop:=SavePlotTop;
end;
MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
PlotHeight+TopMargin+BottomMargin);
Paste;
DoOr;
PlotTop:=PlotTop+PlotHeight-1;
SelectPic(GelWindow);
end;
macro 'Plot Overlayed [O]';
var
left,top,width,height:integer;
begin
if (GelWidth=0) or (nPics=1) then begin
PutMessage('Use Setup first.');
Exit;
end;
if PlotColor=1 then SetPalette('256 Color Spectrum');
GetRoi(left,top,width,height);
MakeRoi(RoiLeft,top,RoiWidth,height);
ColumnAveragePlot;
Copy;
SelectPic(PlotWindow);
if PlotColor=1 then SetPalette('256 Color Spectrum');
SetForegroundColor(PlotColor);
PlotTop:=PlotTop-PlotHeight+1;
if PlotTop<SavePlotTop then PlotTop:=SavePlotTop;
MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
PlotHeight+TopMargin+BottomMargin);
Paste;
DoOr;
PlotTop:=PlotTop+PlotHeight-1;
SelectPic(GelWindow);
PlotColor:=(PlotColor+74) mod 254;
end;